package com.xrf;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ProjectFinancialInfo {
    private Long projectNumber;
    private Double projectName;
    private Double projectTime;
    private String projectContractAmount;
    private String accumulatedSettledIncome;
    private Long accumulatedSettledOutsourcingCost;
    private Long accountsReceivable;
    private String mainStageOfProject;
    private Double salesStage;
    private String currentPhaseOfProject;
    private Long initialTestTimeExpected;
    private Double branchOrDepartment;

    private static List<ProjectFinancialInfo> list = new ArrayList<>();
    private static Scanner scanner = new Scanner(System.in);

    public ProjectFinancialInfo() {}

    public ProjectFinancialInfo(Long projectNumber, Double projectName, Double projectTime,
                              String projectContractAmount, String accumulatedSettledIncome,
                              Long accumulatedSettledOutsourcingCost, Long accountsReceivable,
                              String mainStageOfProject, Double salesStage, String currentPhaseOfProject,
                              Long initialTestTimeExpected, Double branchOrDepartment) {
        this.projectNumber = projectNumber;
        this.projectName = projectName;
        this.projectTime = projectTime;
        this.projectContractAmount = projectContractAmount;
        this.accumulatedSettledIncome = accumulatedSettledIncome;
        this.accumulatedSettledOutsourcingCost = accumulatedSettledOutsourcingCost;
        this.accountsReceivable = accountsReceivable;
        this.mainStageOfProject = mainStageOfProject;
        this.salesStage = salesStage;
        this.currentPhaseOfProject = currentPhaseOfProject;
        this.initialTestTimeExpected = initialTestTimeExpected;
        this.branchOrDepartment = branchOrDepartment;
    }

    // Getter and Setter methods
    public Long getProjectNumber() { return projectNumber; }
    public void setProjectNumber(Long projectNumber) { this.projectNumber = projectNumber; }
    public Double getProjectName() { return projectName; }
    public void setProjectName(Double projectName) { this.projectName = projectName; }
    public Double getProjectTime() { return projectTime; }
    public void setProjectTime(Double projectTime) { this.projectTime = projectTime; }
    public String getProjectContractAmount() { return projectContractAmount; }
    public void setProjectContractAmount(String projectContractAmount) { this.projectContractAmount = projectContractAmount; }
    public String getAccumulatedSettledIncome() { return accumulatedSettledIncome; }
    public void setAccumulatedSettledIncome(String accumulatedSettledIncome) { this.accumulatedSettledIncome = accumulatedSettledIncome; }
    public Long getAccumulatedSettledOutsourcingCost() { return accumulatedSettledOutsourcingCost; }
    public void setAccumulatedSettledOutsourcingCost(Long accumulatedSettledOutsourcingCost) { this.accumulatedSettledOutsourcingCost = accumulatedSettledOutsourcingCost; }
    public Long getAccountsReceivable() { return accountsReceivable; }
    public void setAccountsReceivable(Long accountsReceivable) { this.accountsReceivable = accountsReceivable; }
    public String getMainStageOfProject() { return mainStageOfProject; }
    public void setMainStageOfProject(String mainStageOfProject) { this.mainStageOfProject = mainStageOfProject; }
    public Double getSalesStage() { return salesStage; }
    public void setSalesStage(Double salesStage) { this.salesStage = salesStage; }
    public String getCurrentPhaseOfProject() { return currentPhaseOfProject; }
    public void setCurrentPhaseOfProject(String currentPhaseOfProject) { this.currentPhaseOfProject = currentPhaseOfProject; }
    public Long getInitialTestTimeExpected() { return initialTestTimeExpected; }
    public void setInitialTestTimeExpected(Long initialTestTimeExpected) { this.initialTestTimeExpected = initialTestTimeExpected; }
    public Double getBranchOrDepartment() { return branchOrDepartment; }
    public void setBranchOrDepartment(Double branchOrDepartment) { this.branchOrDepartment = branchOrDepartment; }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("项目编号:").append(projectNumber).append("\t");
        builder.append("项目名称:").append(projectName).append("\t");
        builder.append("立项时间:").append(projectTime).append("\t");
        builder.append("项目合同金额（元）:").append(projectContractAmount).append("\t");
        builder.append("累计已结算收入（元）:").append(accumulatedSettledIncome).append("\t");
        builder.append("累计已结算外购外包成本（元）:").append(accumulatedSettledOutsourcingCost).append("\t");
        builder.append("应收账款（元）:").append(accountsReceivable).append("\t");
        builder.append("项目主阶段:").append(mainStageOfProject).append("\t");
        builder.append("销售阶段:").append(salesStage).append("\t");
        builder.append("项目目前阶段:").append(currentPhaseOfProject).append("\t");
        builder.append("预计初验时间:").append(initialTestTimeExpected).append("\t");
        builder.append("分公司或部门:").append(branchOrDepartment).append("\t");
        return builder.toString();
    }

    public static void addData() {
        System.out.println("--------添加数据-------");
        System.out.println("请输入项目编号：");
        Long projectNumber = scanner.nextLong();
        System.out.println("请输入项目名称：");
        Double projectName = scanner.nextDouble();
        System.out.println("请输入立项时间：");
        Double projectTime = scanner.nextDouble();
        System.out.println("请输入项目合同金额（元）：");
        String projectContractAmount = scanner.next();
        System.out.println("请输入累计已结算收入（元）：");
        String accumulatedSettledIncome = scanner.next();
        System.out.println("请输入累计已结算外购外包成本（元）：");
        Long accumulatedSettledOutsourcingCost = scanner.nextLong();
        System.out.println("请输入应收账款（元）：");
        Long accountsReceivable = scanner.nextLong();
        System.out.println("请输入项目主阶段：");
        String mainStageOfProject = scanner.next();
        System.out.println("请输入销售阶段：");
        Double salesStage = scanner.nextDouble();
        System.out.println("请输入项目目前阶段：");
        String currentPhaseOfProject = scanner.next();
        System.out.println("请输入预计初验时间：");
        Long initialTestTimeExpected = scanner.nextLong();
        System.out.println("请输入分公司或部门：");
        Double branchOrDepartment = scanner.nextDouble();
        
        ProjectFinancialInfo data = new ProjectFinancialInfo(projectNumber, projectName, projectTime,
                                                           projectContractAmount, accumulatedSettledIncome,
                                                           accumulatedSettledOutsourcingCost, accountsReceivable,
                                                           mainStageOfProject, salesStage, currentPhaseOfProject,
                                                           initialTestTimeExpected, branchOrDepartment);
        list.add(data);
    }

    public static void removeData() {
        System.out.println("--------删除数据-------");
        System.out.println("请输入索引：");
        int index = scanner.nextInt();
        if (index >= 0 && index < list.size()) {
            list.remove(index);
            System.out.println("删除成功！");
        } else {
            System.out.println("索引无效！");
        }
    }

    public static void updateData() {
        System.out.println("--------修改数据-------");
        System.out.println("请输入索引：");
        int index = scanner.nextInt();
        if (index >= 0 && index < list.size()) {
            System.out.println("请输入项目编号：");
            Long projectNumber = scanner.nextLong();
            System.out.println("请输入项目名称：");
            Double projectName = scanner.nextDouble();
            System.out.println("请输入立项时间：");
            Double projectTime = scanner.nextDouble();
            System.out.println("请输入项目合同金额（元）：");
            String projectContractAmount = scanner.next();
            System.out.println("请输入累计已结算收入（元）：");
            String accumulatedSettledIncome = scanner.next();
            System.out.println("请输入累计已结算外购外包成本（元）：");
            Long accumulatedSettledOutsourcingCost = scanner.nextLong();
            System.out.println("请输入应收账款（元）：");
            Long accountsReceivable = scanner.nextLong();
            System.out.println("请输入项目主阶段：");
            String mainStageOfProject = scanner.next();
            System.out.println("请输入销售阶段：");
            Double salesStage = scanner.nextDouble();
            System.out.println("请输入项目目前阶段：");
            String currentPhaseOfProject = scanner.next();
            System.out.println("请输入预计初验时间：");
            Long initialTestTimeExpected = scanner.nextLong();
            System.out.println("请输入分公司或部门：");
            Double branchOrDepartment = scanner.nextDouble();
            
            ProjectFinancialInfo data = new ProjectFinancialInfo(projectNumber, projectName, projectTime,
                                                               projectContractAmount, accumulatedSettledIncome,
                                                               accumulatedSettledOutsourcingCost, accountsReceivable,
                                                               mainStageOfProject, salesStage, currentPhaseOfProject,
                                                               initialTestTimeExpected, branchOrDepartment);
            list.set(index, data);
            System.out.println("修改成功！");
        } else {
            System.out.println("索引无效！");
        }
    }

    public static void displayData() {
        System.out.println("--------数据显示-------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println("索引 " + i + ": " + list.get(i));
        }
    }
}